package ijen.fbconnect.services;

import ijen.fbconnect.FBRequest;

import java.io.File;

/**
 * Description of FBPhotoService.
 * ---------------------------------------------------------------------------------------
 * User: fred
 * Date: 24 juil. 2009
 * Time: 14:03:48
 * ---------------------------------------------------------------------------------------
 */
public final class FBPhotoService extends FBAbstractService {

    /**
     * <p>Upload a photo.
     * @param pCaption File name
     * @param pFile File itself as byte array
     * @return  Configured FBRequest
     */
    public FBRequest upload(final String pCaption, final File pFile) {

        FBRequest result = new FBRequest("facebook.photos.upload");

        result.getParameters().put("", pFile.toString());

        result.getParameters().put("caption", pCaption);
        result.needsMultipartEncoding();

        return result;
    }


    /**
     * <p>Complete version of the upload phot API call (without callback though, might be added afterward).
     * @param pFile File to upload
     * @param pCaption Cpation of file in album
     * @param pAlbumId Album
     * @param pUid Selected uid
     * @return Configured FBRequest
     */
    public FBRequest upload(final File pFile, final String pCaption, final String pAlbumId, final String pUid) {

        FBRequest result = upload(pCaption, pFile);

        if (pAlbumId != null && pAlbumId.length() < 51) {
            result.getParameters().put("aid", pAlbumId);
        }

        if (pUid != null) {
             result.getParameters().put("uid", pUid);
        }

        return result;

    }

}
